package com.sdi.acciones;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sdi.business.UserService;
import com.sdi.business.exception.EntityNotFoundException;
import com.sdi.infrastructure.Factories;

import com.sdi.model.User;

public class ActivarCuentaAction implements Action {

	@Override
	public String execute(HttpServletRequest request, HttpServletResponse res,
			ServletContext context) {
		
		UserService service;
		User user;
	
	
		
		String nick= (String) request.getParameter("usuarioActivar");
		service = Factories.services.createUserService();
		
		try {
			user= service.findByNick(nick);
			user.setActivada(1);
			service.updateUser(user);
			new CargarDatosAction().execute(request, res, context);
			return "EXITO";
		} catch (EntityNotFoundException e) {
			return "FRACASO";
		}
		
		
			
			
	}

}
